<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\ColorRep;
use Illuminate\Http\Request;

class Color extends Controller
{
    //产品颜色管理
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new ColorRep();
    }

    /**
     * 获取产品颜色列表
     * @param Request $request
     */
    public function getColorList(Request $request){
        $params = $request->all();
        $data = $this->rep->getColorListRep($params);
        return re(0,$data,'success');
    }

    /**
     * 添加颜色
     * @param Request $request
     */
    public function createColor(Request $request){
        $params = $request->all();
        $data = $this->rep->createColorRep($params);
        return re($data['code'],$data['data']);
    }

    /**
     * 删除颜色
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function delColor(Request $request){
        $params = $request->all();
        $data = $this->rep->delColorRep($params);
        return re($data['code']);
    }

}
